package mason.dp.singleton;

/**
 * 用单例模式实现的简单Log工具类
 * @author MasonAir
 *
 */
public class LogUtil {
	private final int DEGUB = 0;
	private final int INFO = 1;
	private final int ERROR = 2;
	//只能在这里设置level，其他地方不可设置
	private int level = DEGUB;
	private static LogUtil logInstance = null;

	private LogUtil() {
	}

	public static LogUtil getInstance() {
		if (logInstance == null) {
			synchronized (LogUtil.class) {
				if (logInstance == null) {
					logInstance = new LogUtil();
				}
			}
		}
		return logInstance;
	}
	
	public void debug(Object o) {
		if(DEGUB>=level){
			System.out.println("debug---: "+o.toString());
		}
	}
	
	public void info(Object o) {
		if(INFO>=level) {
			System.out.println("info---: "+o.toString());
		}
	}
	
	public void error(Object o) {
		if(ERROR>=level) {
			System.out.println("error---: "+o.toString());
		}
	}

}
